package org.bits.data;

import java.util.List;
import java.util.Vector;

/*******************************************************************************
 * 
 ******************************************************************************/
public class FilterCondition
{
    /**
     * Defines the top level logical operator used for the data and sub-filter
     * conditions
     */
    private final LogicalType type;
    /** The tests for fields. */
    private List<DataCondition> dataConditions;
    /** Sub-conditions used to group data conditions. */
    private List<FilterCondition> filterConditions;

    /***************************************************************************
     * Constructor
     * @param type
     **************************************************************************/
    public FilterCondition( LogicalType type )
    {
        this.type = type;

        dataConditions = new Vector<DataCondition>();
        filterConditions = new Vector<FilterCondition>();
    }

    /***************************************************************************
     * Adds a {@link DataCondition} to the list.
     * @param cond
     **************************************************************************/
    public void addDataCondition( DataCondition cond )
    {
        dataConditions.add( cond );
    }

    /***************************************************************************
     * Adds a {@link FilterCondition} to the list.
     * @param cond
     **************************************************************************/
    public void addFilterCondition( FilterCondition cond )
    {
        filterConditions.add( cond );
    }

    /***************************************************************************
     * Returns the type of this condition.
     * @return
     **************************************************************************/
    public LogicalType getType()
    {
        return type;
    }

    /***************************************************************************
     * Returns the {@link DataCondition}s associated with this condition.
     * @return
     **************************************************************************/
    public List<DataCondition> getDataConditions()
    {
        return dataConditions;
    }

    /***************************************************************************
     * Returns the {@link FilterCondition}s associated with this condition.
     * @return
     **************************************************************************/
    public List<FilterCondition> getFilterConditions()
    {
        return filterConditions;
    }
}
